<?php
	DEFINE('H1', 'Make Select 1');
	DEFINE('TITLE','Make Select 1');
	require('includes/header.php');
?>	
	<h2><?PHP echo H1 ?></h2>

<?php
class Element {
private $name;
private $value;
private $label;

public function __construct () {
}
public function setName ($name) {
$this->name = $name;
}
public function getName () {
return $this->name;
}
public function setValue($value) {
$this->value = $value;
}
public function getValue() {
return $this->value;
}
public function setLabel ($label) {
$this->label = $label;
}
public function getLabel() {
return $this->label;
}
}
?>
<?php
class Option extends Element {

public function __construct($value='', $label='') {
parent::__construct();
$this->setValue($value);
$this->setLabel($label);
}

public function render() {
echo "<option value=\"" . $this->getValue() . "\">" . $this->getLabel() . "</option>\n";
}
}
?>
<?php 
class Select extends Element {
protected $options;
public function _construct(){
parent::_construct();
$this->options = array();
}
public function setOption($option) {
$this->options[] = $option;
}
private function getOption() {
return (array)$this->options;
}
public function render() {
echo $this->getLabel() . ": <br />\n";
echo "<select name=\"" . $this->getName() . "\">\n";
foreach ($this->getOption() as $opt) {
echo $opt->render();
}
echo "</select>";
}
}
?>

<?php if (!isset($_POST['submit'])) { ?>
<form method="post" action="MakeSelect1.php">
<?php 
$fruits = new Select();
$fruits->setLabel('Fruits');
$fruits->setName('fruit_sel');
$fruits->setOption(new Option('Oranges', 'Oranges'));
$fruits->setOption(new Option('Strawberries', 'Strawberries'));
$fruits->setOption(new Option('Pineapples', 'Pineapples'));
$fruits->setOption(new Option('Bananas', 'Bananas'));
$fruits->render();
?>
<br /><br />
<?php 
$metals = new Select();
$metals->setLabel('Metal');
$metals->setName('metal_sel');
$metals->setOption(new Option('Iron', 'Iron'));
$metals->setOption(new Option('Silver', 'Silver'));
$metals->setOption(new Option('Gold', 'Gold'));
$metals->setOption(new Option('Platinum', 'Platinum'));
$metals->render();
?>
<br /><br />
<?php 
$animals = new Select();
$animals->setLabel('Animals');
$animals->setName('animal_sel');
$animals->setOption(new Option('Lion', 'Lion'));
$animals->setOption(new Option('Hyena', 'Hyena'));
$animals->setOption(new Option('Fox', 'Fox'));;
$animals->render();
?><br /><br />
<input type="submit" name="submit" value="Submit" />
</form>
<?php } else {
	var_dump($_POST);
	}
	?>


<?php
	require('includes/footer.php');
?>